import axios, { type Axios } from 'axios';
// import NProgress from 'nprogress';

axios.defaults.withCredentials = true;

const apiClient: Axios = axios.create({
  baseURL: process.env.NODE_ENV === 'development' ? '/Api/v1/' : '/',
  withCredentials: true,
});
apiClient.interceptors.request.use(
  (config) => {
    // NProgress.start();
    return config;
  },
  (error) => {
    return Promise.reject(error);
  },
);
apiClient.interceptors.response.use(
  (response) => {
    return response;
  },
  error => Promise.resolve(error.response),
);
export default apiClient;
